package ru.gerunn.silent.io;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import ru.gerunn.silent.message.Message;
import ru.gerunn.silent.message.TextMessage;

public class ConsoleReader implements Reader {

	private final BufferedReader reader;

	public ConsoleReader() {
		reader = new BufferedReader(new InputStreamReader(System.in));
	}

	public Message read() throws ReaderException {
		try {
			String string = reader.readLine();
			return string == null ? null : new TextMessage(string);
		} catch (IOException e) {
			throw new ReaderException(e);
		}
	}

}
